﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MyLocalChurch.Models.KidsChurch
{
    public class ReportDetail : IComparable<ReportDetail>
    {
        public string ChurchService { get; set; }
        public string Category { get; set; }
        public string Name { get; set; }
        public string CheckInTime { get; set; }
        public string CheckOutTime { get; set; }

        public int CompareTo(ReportDetail other)
        {
            DateTime? dtCheckInTime = null;
            DateTime? dtOtherCheckInTime = null;

            DateTime dt;
            if (DateTime.TryParse(CheckInTime, out dt))
                dtCheckInTime = dt;
            if (DateTime.TryParse(other.CheckInTime, out dt))
                dtOtherCheckInTime = dt;

            if (!dtCheckInTime.HasValue && !dtOtherCheckInTime.HasValue)
                return 0;

            if (dtCheckInTime.HasValue && !dtOtherCheckInTime.HasValue)
                return 1;

            if (!dtCheckInTime.HasValue && dtOtherCheckInTime.HasValue)
                return -1;

            return dtCheckInTime.Value.CompareTo(dtOtherCheckInTime.Value);
        }
    }
}